<template>
  <div class="detail">
    <Myheader/>
    <WhiteSpace :space="30"/>
    <div class="box">
      <div class="left">
        <div class="pic">
          <img :src="goods.img_big_logo" alt="">
        </div>
      </div>
      <div class="right">
        <div class="title">{{ goods.title }}</div>
        <div class="price">
          <div class="curr">{{ goods.current_price }}</div>
          <div class="prev">{{ goods.price }}</div>
        </div>
        <div class="btns">
          <button>立即购买</button>
          <button>加入购物车</button>
        </div>
      </div>
    </div>
    <div class="bottom">
      <h3>详细介绍</h3>
      <div class="introduce" v-html="goods.goods_introduce">
      </div>
    </div>
  </div>
</template>

<script>
import { getGoodsItem } from '@/service/shop';

export default {
  props: ['id'],
  data() {
    return {
      goods: {

      }
    }
  },
  methods: {
    async getGoodsItemData() {
      const res = await getGoodsItem(this.id);
      console.log(res);
      const { code, info } = res || {};
      if (code !== 1) return;
      this.goods = info || {};
    }
  },
  mounted() {
    this.getGoodsItemData();
  },
};
</script>

<style lang="scss" scoped>
.detail {
  .box {
    display: flex;
    justify-content: space-between;
    box-sizing: border-box;
    width: 80vw;
    margin: 0 auto;
    .left {
      width: 35vw;
      .pic {
        width: 35vw;
        height: 35vw;
        img {
          width: 100%;
        }
      }
    }
    .right {
      width: 35vw;
      padding: 10px;
      background-color: pink;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .title {
        font-size: 30px;
      }
      .price {
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 100px;
        font-size: 24px;
        color: red;
         > div {
          width: 20vw;
          display: flex;
          justify-content: center;
         }
        .prev {
          font-size: 16px;
          text-decoration: line-through;
          color: #ccc;
        }
      }
      .btns {
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 40px;
        padding: 0 20px;
        box-sizing: border-box;
        button {
          width: 15vw;
          height: 40px;
          cursor: pointer;
        }
      }
    }
  }
  .bottom {
    h3 {
      width: 100vw;
      display: flex;
      justify-content: center;
    }
    .introduce {
      width: 80vw;
      margin: 0 auto;
    }
  }
}
</style>
